package com.common.baseconstant;



import java.util.Map;

/**
 * 返回前端的响应标志(returnCode)
 * 类似如JSON格式：
 *   {"returnCode":"SUCCESS"}
 * @author zhongqiu
 * @date 2016年5月27日
 * @time 上午8:47:52
 */
public final class MapJson {
	
	public static final String RETURN_CODE = WebCommonConstant.RETURN_CODE;
	
	public static final Map<String,Object> PARAM_ERROR_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.PARAM_ERROR).getMap();
	
	public static final Map<String,Object> NOT_LOGIN_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.NOT_LOGIN).getMap();
	
	public static final Map<String,Object> FAIL_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.FAIL).getMap();
	
	public static final Map<String,Object> SUCCESS_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.SUCCESS).getMap();
	
	public static final Map<String,Object> SYSTEM_ERROR_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.SYSTEM_ERROR).getMap();
	
	public static final Map<String,Object> DUPLICATION_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.DUPLICATION).getMap();
	
	public static final Map<String,Object> NO_EXIST_MAP = 
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.NO_EXIST).getMap();

	public static final Map<String,Object> NO_AUTH_MAP =
			new MapBuilder<String,Object>(1).put(RETURN_CODE,ReturnCode.NO_AUTH).getMap();
	
	private MapJson(){}
	
	public static Map<String,Object> mapJson(ReturnCode returnCode){
		switch (returnCode) {
		case PARAM_ERROR : return PARAM_ERROR_MAP;
		case SYSTEM_ERROR : return SYSTEM_ERROR_MAP;
		case FAIL : return FAIL_MAP;
		case DUPLICATION : return DUPLICATION_MAP;
		case NO_EXIST : return NO_EXIST_MAP;
		case SUCCESS : return SUCCESS_MAP;
		case NOT_LOGIN : return NOT_LOGIN_MAP;
		default : return null;
		}
	}
}
